<?php
namespace App\Listener\Order;

use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Event\Annotation\Listener;

use App\Query\OrderQuery;
use App\Job\PrizeJob;

/**
 * @Listener 
 */
class PrizeJobListener implements ListenerInterface
{
    public function listen(): array
    {
        return [ 
            \App\Event\Order\StatusOkEvent::class,
        ];
    }
    
    // 奖励
    public function process($event)
    {
        // 奖励任务
        (new PrizeJob)->push(
            $event->user->id, 
            $event->order->total,
            // 订单数量
            OrderQuery::statusOk(OrderQuery::user($event->user))->count()
        );
    }
}